package day9.problem3;

import java.util.*;

//扑克牌顺子
//https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&ru=/exam/oj

public class Solution {
    public boolean IsContinuous (int[] nums) {
        int[] hash = new int[20];
        for(int x : nums) {
            hash[x]++;
        }
        int len = 0, max = 0;
        for(int i = 1; i<14; i++) {
            if(hash[i] != 0) {
                len++;
                max = Math.max(max, len);
            }else if(hash[0] > 0 && len > 0){
                len++;
                hash[0]--;
                max = Math.max(max, len);
            }else {
                len = 0;
            }
        }
        if(max + hash[0] == 5) return true;
        return false;
    }
}

/*
1 2 3 4 6
*/